package com.sdtv.mediunfusion.mvp.ui.outsidetask.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.sdtv.mediunfusion.R;
import com.sdtv.mediunfusion.base.adapter.IPullToRefreshListAdapter;
import com.sdtv.mediunfusion.bean.StatusBean;

/**
 * 外采任务列表页
 * 状态栏选项
 */
public class StatusAdapter extends IPullToRefreshListAdapter<StatusBean> {


    public StatusAdapter(Context context) {
        super(context);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (null == convertView) {
            convertView = inflater.inflate(R.layout.status_layout, null);
            viewHolder = new ViewHolder();
            viewHolder.nameView = convertView.findViewById(R.id.filter_status_name);
            viewHolder.checkImg = convertView.findViewById(R.id.status_checked);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        StatusBean item = getItem(position);
        viewHolder.nameView.setText(item.getName());

        if (item.isSelected()) {
            viewHolder.checkImg.setVisibility(View.VISIBLE);
            viewHolder.nameView.setTextColor(context.getResources().getColor(R.color.status_select_color));
        } else {
            viewHolder.checkImg.setVisibility(View.GONE);
            viewHolder.nameView.setTextColor(context.getResources().getColor(R.color.color_3333));
        }

        return convertView;
    }


    static class ViewHolder {

        TextView nameView;
        ImageView checkImg;

    }
}
